﻿<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                    xmlns:CustomUserControl="clr-namespace:GBlason.Control.CustomUserControl"
                    xmlns:Contract="clr-namespace:GBlason.ViewModel.Contract"
                    xmlns:ViewModel="clr-namespace:GBlason.ViewModel"
                    xmlns:CustomCommand="clr-namespace:GBlason.Common.CustomCommand"
                    xmlns:General="clr-namespace:GBlason.ViewModel.General">

    <ResourceDictionary.MergedDictionaries>
        <ResourceDictionary Source="..\Themes\Brushes.xaml"/>
    </ResourceDictionary.MergedDictionaries>

    <!-- Default shape display -->
    <DataTemplate x:Key="PropertyTableCellItemTemplate" DataType="{x:Type Contract:PropertyDisplayer}">
        <CustomUserControl:CommandComboBox x:Name="ShapeComboBoxProperty" ItemsSource="{Binding Source={x:Static General:GbrFileViewModel.GetResources}, Path=ScaledForMenuShapeResources}"
                                           SelectedValue="{Binding Path=PropertyValue, Mode=OneWay}"
                                           Command="CustomCommand:CommandMenu.ChangingShape"
                                           CommandParameter="{Binding RelativeSource={RelativeSource Self}, Path=SelectedItem}"
                                           CommandTarget="{Binding Source={x:Static Member=General:GlobalApplicationViewModel.GetApplicationViewModel}, Path=CurrentlyDisplayedFile.RootCoatOfArm}">
            <CustomUserControl:CommandComboBox.ItemTemplate>
                <DataTemplate>
                    <DockPanel Margin="2">
                        <Viewbox HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Margin="0" MaxHeight="30" DockPanel.Dock="Left">
                            <Path Data="{Binding Path=Geometry}" Stroke="Black" StrokeThickness="3" Fill="{StaticResource ResourceKey=CustomMiniShapeGlossyBrush}">
                            </Path>
                        </Viewbox>
                        <TextBlock HorizontalAlignment="Stretch" VerticalAlignment="Center" Margin="4,2,3,2" MaxHeight="26"
                                   Text="{Binding Path=LocalizedName}" Foreground="Black"/>
                    </DockPanel>
                </DataTemplate>
            </CustomUserControl:CommandComboBox.ItemTemplate>

        </CustomUserControl:CommandComboBox>
        <!--<Viewbox HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Margin="0" MaxHeight="30">
            <Path Data="{Binding Path=PropertyValue.Geometry}"
                  Fill="Black">
            </Path>
        </Viewbox>-->
    </DataTemplate>

    <!-- Default Color display (temp) -->
    <DataTemplate x:Key="PropertyTableColorSelectorItemTemplate" DataType="{x:Type Contract:PropertyDisplayer}">
        <CustomUserControl:CommandComboBox x:Name="ColorComboBoxProperty" 
                                           ItemsSource="{Binding Source={x:Static General:GbrFileViewModel.GetResources}, Path=AvailableTinctures}"
                                           SelectedValue="{Binding Path=PropertyValue, Mode=OneWay}"
                                           Command="CustomCommand:CommandMenu.ChangingColor"
                                           CommandParameter="{Binding RelativeSource={RelativeSource Self}, Path=SelectedItem}"
                                           CommandTarget="{Binding Source={x:Static Member=General:GlobalApplicationViewModel.GetApplicationViewModel}, Path=CurrentlyDisplayedFile.CurrentlySelectedComponent}">
            <CustomUserControl:CommandComboBox.ItemTemplate>
                <DataTemplate>
                    <DockPanel Margin="2">
                        <Border Background="{Binding Path=ColorForSmallDisplay}"
                                Width="16" Height="16"
                                BorderBrush="Black"
                                BorderThickness="1"
                                DockPanel.Dock="Left"
                                Margin="2,0,4,0">
                            <Border Background="{StaticResource CustomMiniShapeGlossyBrush}"/>
                        </Border>
                        <TextBlock HorizontalAlignment="Stretch" VerticalAlignment="Center" Margin="4,2,3,2" MaxHeight="26"
                                   Text="{Binding Path=LocalizedName}" Foreground="Black"/>
                    </DockPanel>
                </DataTemplate>
            </CustomUserControl:CommandComboBox.ItemTemplate>

        </CustomUserControl:CommandComboBox>
        <!--<Viewbox HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Margin="0" MaxHeight="30">
            <Path Data="{Binding Path=PropertyValue.Geometry}"
                  Fill="Black">
            </Path>
        </Viewbox>-->
    </DataTemplate>

    <!-- The grid in the properties -->

    <Style x:Key="DataGridCellStyle" TargetType="{x:Type DataGridCell}">
        <Setter Property="Background" Value="Transparent" />
        <Setter Property="BorderBrush" Value="Transparent" />
        <Setter Property="BorderThickness" Value="1" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type DataGridCell}">
                    <Border Background="Transparent" 
                            BorderBrush="{TemplateBinding BorderBrush}"  
                            BorderThickness="0"
                            SnapsToDevicePixels="True"
                            Margin="1,3,1,3">
                        <ContentPresenter x:Name="Content" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"/>
                    </Border>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsSelected" Value="true">

                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <!-- The grid in the command's history -->

    <DataTemplate x:Key="CommandGenericDataTemplate" DataType="{x:Type CustomCommand:CommandGeneric}">
        <TextBlock HorizontalAlignment="Left" VerticalAlignment="Center"
                   Margin="4,1" TextWrapping="Wrap" x:Name="ContentPresenter"
                   Text="{Binding Path=Description}"/>
        <DataTemplate.Triggers>
            <DataTrigger Binding="{Binding Path=Done}" Value="True">
                <Setter TargetName="ContentPresenter" Property="Foreground" Value="{StaticResource CustomDefaultBorder}"/>
            </DataTrigger>
            <DataTrigger Binding="{Binding Path=Done}" Value="False">
                <Setter TargetName="ContentPresenter" Property="Foreground" Value="{StaticResource FontDisabledBackgroundBrush}"/>
                <Setter Property="FontStyle" TargetName="ContentPresenter" Value="Italic"/>
            </DataTrigger>
        </DataTemplate.Triggers>
    </DataTemplate>
    
    <Style x:Key="DataGridCommandHistoryCellStyle" TargetType="{x:Type DataGridCell}">
        <Setter Property="Background" Value="Transparent" />
        <Setter Property="BorderBrush" Value="Transparent" />
        <Setter Property="BorderThickness" Value="1" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type DataGridCell}">
                    <Border Name="Bd"
                                    Grid.ColumnSpan="4"
                                    BorderBrush="Transparent"
                                    BorderThickness="1"
                                    Padding="0"
                                    Margin="1">

                        <Grid>
                            <Grid.RowDefinitions>
                                <RowDefinition Height="0.5*"/>
                                <RowDefinition Height="0.5*"/>
                            </Grid.RowDefinitions>
                            <Border HorizontalAlignment="Stretch" Margin="0" Padding="0"
                                            Grid.RowSpan="2" Grid.ColumnSpan="4"
                                            Name="glow" Opacity="0" Background="{StaticResource GlowBrush}">
                            </Border>
                            <Border HorizontalAlignment="Stretch" Margin="0" Padding="0"
                                            Grid.ColumnSpan="4" Name="glossy"
                                            Opacity="0" Background="{StaticResource GlossyBrush}">
                            </Border>
                            <Border Background="Transparent" 
                                    BorderBrush="{TemplateBinding BorderBrush}"  
                                    BorderThickness="0"
                                    Grid.RowSpan="2"
                                    SnapsToDevicePixels="True"
                                    Margin="1,3,1,3">
                                <ContentPresenter x:Name="Content" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"/>
                            </Border>
                        </Grid>
                    </Border>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsSelected" Value="true">
                            <Setter TargetName="Bd" Property="Background" Value="{StaticResource ResourceKey=SelectedGrayBackgroundBrush}"/>
                            <Setter TargetName="glow" Property="Opacity" Value="1"/>
                            <Setter TargetName="glossy" Property="Opacity" Value="1"/>
                            <Setter TargetName="glossy" Property="Opacity" Value="1"/>
                            <Setter TargetName="Bd" Property="BorderBrush" Value="{StaticResource ResourceKey=SelectedGrayBorderBrush}"/>
                        </Trigger>
                        <Trigger Property="IsMouseOver" Value="True">
                            <Setter TargetName="Bd" Property="Background" Value="{StaticResource ResourceKey=YellowBackgroundBrush}"/>
                            <Setter TargetName="glow" Property="Opacity" Value="1"/>
                            <Setter TargetName="glossy" Property="Opacity" Value="1"/>
                            <Setter TargetName="Bd" Property="BorderBrush" Value="{StaticResource ResourceKey=DarkYellowBorderBrush}"/>
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

</ResourceDictionary>